
BEGIN{
    command_name = ENVIRON["command_name"]
}

$0~"^[A-Za-z0-9_-]+"{
    print "\033[36;40;7;1m" $0 "\033[0m"
    next
}

BEGIN {
    PAT = "(\\{[^\\}]+[}])" "|" "(\\([^\\)]+[)])" "|" "(<[^>]+>)" "|" "(`[^>]+`)"
    PAT = PAT "|"       "(\\[[^\\]]+\\])"

    PAT = PAT "|"       "(^|[ ])[^:]://.+([ ,.]|$)"
    PAT = PAT "|"       "(^|[ ])/[^/]+(/[^/]+)*([ ,.]|$)"
    PAT = PAT "|"       "(^[ ]+[0-9]+\\.[ ])"


    EMP = "(^[ ]+[0-9]+\\.[ ])"
    EMP = EMP "|"       "(^[ ][ ]+[^ ]+[ ][ ])"
}

{
    gsub(".", "", $0)  # Very strange ...
    # gsub(/\033\[[^m]m/, "", $0)

    gsub(PAT, "\033[36m" "&" "\033[0m", $0)

    gsub("(^|[ \t])[-]?-[A-Za-z0-9_-]+([ ,.]|$)", "\033[32m" "&" "\033[0m", $0)


    gsub("([ ]+|^)[^:]+:([ ]|$)", "\033[33m" "&" "\033[0m", $0)
    gsub(EMP, "\033[33m" "&" "\033[0m", $0)

    if ("" != command_name) {
        gsub(command_name, "\033[31m" command_name "\033[0m",  $0)
        print $0
    } else {
        print $0
    }
}
